#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <climits>
#include <unordered_map>

using namespace std;
class Solution {
public:
    bool checkSubarraySum(vector<int>& nums, int k) {
        int m=nums.size();
        if(m<2){
            return false;
        }
        unordered_map<int,int> mp;
        mp[0]=-1;
        int f=0;
        for(int i=0;i<m;i++){
            f=(f+nums[i])%k;
            if(mp.count(f)){
                int p=mp[f];
                if(i-p>=2) return true;
            }else{
                mp[f]=i;
            }
        }
        return false;
    }
};

int main(){
    vector<int> v={23,2,4,6,7};
    Solution s;
    cout << s.checkSubarraySum(v,6) <<endl;



    return 0;
}